﻿using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class _Default : System.Web.UI.Page 
{
    public string NavigatorType
    {
        get
        {
            //if (Request.QueryString["NT"] != null)
            //    return Request.QueryString["NT"];
            //else
                return "";
        }
    }

    public string FolderName
    {
        get
        {
            if (Request.QueryString["FN"] != null)
                return Request.QueryString["FN"];
            else
                return "";
        }
    }

    public string CurrentNode
    {
        get
        {
            if (Request.QueryString["CN"] != null)
                return Request.QueryString["CN"];
            else
                return "0";
        }
    }

    public string WebVersion;

    protected void Page_Load(object sender, EventArgs e)
    {
        bool DExists = false;
        System.IO.DirectoryInfo di = new System.IO.DirectoryInfo(Server.MapPath("Courses/"));
        foreach(System.IO.DirectoryInfo dinfo in di.GetDirectories())
        {
            if (dinfo.Name == FolderName)
            {
                DExists = true;
                break;
            }
        }
        if (!DExists)
        {
            WebIMS.Visible = false;
            Silverlight1.Visible = false;
            Response.Redirect("~/Default.aspx?Message=No Cartridge Uploaded for this Course");
        }

        WebIMS.FolderName = FolderName;

        if (NavigatorType == "SL")
        {
            Silverlight1.Source = "~/ClientBin/IMS_Navigator.xap";
            Silverlight1.Visible = true;
            WebIMS.Visible = false;
            WebVersion = "false";
        }
        else
        {
            Silverlight1.Visible = false;
            WebIMS.Visible = true;
            WebVersion = "true";
        }
    }
}
